package com.leen.user.controller;

import com.leen.common.vo.ResultEnum;
import com.leen.common.vo.ResultVO;
import com.leen.user.dto.YxUserBillDTO;
import com.leen.user.entity.YxUserBill;
import com.leen.user.repository.YxUserBillRepository;
import com.leen.user.service.YxUserBillService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.xml.ws.Response;

/**
 * 用户账单API
 */
@RestController
@Api(tags = "用户账单API")
@RequestMapping("/yxuserbill")
public class YxUserBillController {

    @Autowired
     private YxUserBillService yxUserBillService;

    @ApiOperation(value = "分页查询数据")
    @GetMapping(value = "/yxuserbill/pagedata")
    public ResultVO<Response> search(YxUserBillDTO yxUserBillDTO){
        return ResultVO.success(this.yxUserBillService.search(yxUserBillDTO));
    }

    @ApiOperation(value = "新增数据")
    @PostMapping(value = "yxuserbill/add")
    public ResultVO<String>add(@RequestBody YxUserBill yxUserBill){
        YxUserBill save = this.yxUserBillService.save(yxUserBill);
        return save!=null?ResultVO.success(ResultEnum.DB_SUCCESS):ResultVO.failed(ResultEnum.DB_FAILED);
    }
    @ApiOperation(value = "修改数据")
    @PostMapping(value = "/yxuserbill/update")
    public ResultVO<String> update(@RequestBody YxUserBill yxUserBill){
        YxUserBill update = this.yxUserBillService.save(yxUserBill);
        return update!=null?ResultVO.success(ResultEnum.DB_SUCCESS):ResultVO.failed(ResultEnum.DB_FAILED);

    }

//    @ApiOperation(value ="删除数据" )
//    @GetMapping(value = "/yxuserbill/delete")
//    public ResultVO<String>delete(Long id){
//        this.yxUserBillService.deleteById(id);
//        return ResultVO.success(ResultEnum.DB_SUCCESS);
//    }
}
